﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UserPower.ViewModels;

namespace UserPower.Controllers
{
    /// <summary>
    /// 本控制器可以匿名访问
    /// </summary>
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Login()
        {
            LoginData loginData = new LoginData();
            return View(loginData);
        }

        public ActionResult Logout()
        {
            Session.Abandon();
            return RedirectToAction("Login");
        }


        [HttpPost]
        public ActionResult Login(LoginData loginData)
        {
            if (ModelState.IsValid) { 
                var username = loginData.UserName;
                var pswd = loginData.Password;
                Session["loginStat"] = true;
            }
            return View(loginData);
        }

    }
}